#ifndef _BUFFER_H
#define _BUFFER_H


/* class Buffer:
 * This class will hold m_length*m_fps temp images that will simulate a video backup
 * of the last #m_length seconds.
 * When the video is supposed to be exported - it will be build with those images.
 * The user should provide m_length, m_fps upon object creation.
 * Also, make sure that the library LOG_PATH exists 
 * (or change it as you like but leave the "\\car")
 *
 * List of members:
 * 	int m_i - current image index
 *	int m_length - log's length in seconds
 *	int m_fps - frames per second
 *	CvSize m_frame_size - frame size
 *	IplImage* *m_images - array of images
 *	char m_path[PATH_LENGTH] - a buffer to save the current path to save the log to
 *
 * List of member functions:
 *	void saveImage( IplImage *img ) -
 *		this function adds an image to the log of the last #m_length seconds.
 *	char* createVideoLog( int id ) -
 *		this function creates the video log from the current images in the log buffer.
 *		you must use the path returned immidiately, or save it in a variable since
 *		it will be overwritten the next time you create a log file.
 *		suggested use method: string s( createVideoLog( int id ) )
 *		the path where the log file will be saved is: LOG_PATH^id^.avi
 *		exmple: LOG_PATH = "log\\car", id = 10 
 *				==> file path: %project directory%\log\car10.avi
 */


#include <cv.h>
#include <cxcore.h>
#include <highgui.h>


#define LOG_PATH "log\\car"	// where would you like to save the log files?
#define PATH_LENGTH 80		// the length of the m_path buffer


class Buffer{
	int m_i;
	int m_length;
	int m_fps;
	CvSize m_frame_size;
	IplImage* *m_images;
	char m_path[PATH_LENGTH];

public:
	Buffer( int len, int fps );
	~Buffer();

	void saveImage( IplImage *img );
	char* createVideoLog( int id );
};


#endif
